package com.moss.web;

import com.moss.common.core.BaseController;
import com.moss.common.domain.AjaxResult;
import com.moss.common.domain.TreeEntity;
import com.moss.common.entity.SysOrgEntity;
import com.moss.system.service.OrgService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 监管归属
 */
@RestController
@RequestMapping("org")
public class OrgController extends BaseController {

    @Resource
    OrgService orgService;


    @GetMapping("/treeList")
    public AjaxResult<List<TreeEntity>> treeList(){
        String orgId = getOrgId();
        List<SysOrgEntity> orgList = orgService.selectList(orgId);
        List<TreeEntity> tree = orgService.buildTree(orgList);
        return AjaxResult.success(tree);
    }
}
